package com.hsshy.beam.excel.listener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.hsshy.beam.excel.domain.ExportInfo;
import lombok.Data;
import org.springframework.beans.BeanUtils;
import java.util.ArrayList;
import java.util.List;

@Data
public class ExportInfoListener extends AnalysisEventListener {
    private List<Object> datas = new ArrayList<Object>();
    @Override
    public void invoke(Object object, AnalysisContext context) {
        ExportInfo exportInfo = new ExportInfo();
        BeanUtils.copyProperties(object,exportInfo);
        System.out.println("当前行："+context.getCurrentRowNum());
        System.out.println(exportInfo);
        datas.add(exportInfo);
        doSomething(object);
    }
    private void doSomething(Object object) {
        //1、入库调用接口
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
